package com.ztomorrow.ying_cun_plus.controller;

import com.ztomorrow.ying_cun_plus.dto.resp.NewsInfoRespDto;
import com.ztomorrow.ying_cun_plus.dto.resp.RestResp;
import com.ztomorrow.ying_cun_plus.service.NewsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/front/news")
public class NewsController {

    private final NewsService newsService;

    /**
     * 最新新闻列表查询接口
     */
    @GetMapping("/latest_list")
    public RestResp<List<NewsInfoRespDto>> listLatestNews() {
        return newsService.listLatestNews();
    }

    /**
     * 新闻信息查询接口
     */
    @GetMapping("{id}")
    public RestResp<NewsInfoRespDto> getNews( @PathVariable Long id) {
        return newsService.getNews(id);
    }
}
